package com.wei800.turnover.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wei800.common.util.bean.DeepBeanUtils;
import com.wei800.dto.UserDTO;
import com.wei800.service.IUserService;
import com.wei800.turnover.entity.User;
import com.wei800.turnover.mapper.IUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service // 自动实例化
public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements IUserService<User> {
    @Autowired
    private IUserMapper userMapper; // 注入对象实例
    @Override
    public boolean add(UserDTO dto) {
        User user = new User(); // 创建Entity实例
        DeepBeanUtils.copyProperties(dto, user); // DTO内容拷贝到Entity对象
        return this.userMapper.doCreate(user);
    }
}
